﻿
namespace Mal.Balades.Admin.Repositories
{
    public delegate void RepositoryLoadedEventHandler();

    public abstract class RepositoryBase
    {
        #region Fields
        private bool isLoading = false;        
        private bool isLoaded = false;
        #endregion

        #region Construction / Destruction

        #endregion

        #region enum, struct, class

        #endregion

        #region Properties
        public event RepositoryLoadedEventHandler Loaded;

        public bool IsLoading
        {
            get { return isLoading; }
            private set { isLoading = value; }
        }

        public bool IsLoaded
        {
            get { return isLoaded; }
            private set { isLoaded = value; }
        }
        #endregion

        #region Methods
        public void Load()
        {
            this.IsLoading = true;
            LoadRepository();
        }

        protected void LoadCompleted()
        {
            this.IsLoading = false;
            this.IsLoaded = true;

            if (this.Loaded != null)
                Loaded();
        }

        protected abstract void LoadRepository();
        #endregion

        #region Events

        #endregion


    }
}
